package hang.xipujewelWeb.interceptors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @Title: RequestInfoInterceptor.java
 * @Package hang.xipujewelWeb.interceptor
 * @Description: 请求信息拦截记录
 * @Date 2013-8-31-下午2:44:30
 * @Author: qizai
 * @Version: V1.0.0
 */
@Component
public class RequestInfoInterceptor extends HandlerInterceptorAdapter {
	private static Logger logger = LoggerFactory.getLogger(RequestInfoInterceptor.class);
	// 实际的处理器执行前被调用
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		logger.info("IP:{},访问资源:{}", request.getRemoteHost(), request.getRequestURI());
		return super.preHandle(request, response, handler);
	}

	// 后处理程序执行
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		super.postHandle(request, response, handler, modelAndView);
	}

	// 请求完全结束后
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
		super.afterCompletion(request, response, handler, ex);
	}

}
